/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 * 
 * If you have edited the file, please update
 * all the last-modified fields manually. Thanks!
 *
 * @last-modified by: 
 * @last-modified date: 
 * @last-modified time: 
 *
 * @author Swee Zhi
 * @date-created Oct 25, 2011    @time-created 4:25:42 PM
 *
 * @project: 
 * @module: 
 * @institution: 
 *
 */
package util.comboloader;

import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.model.SelectItem;
import util.enumeration.Time24H;
import util.enumhelper.LocalizedTime24H;
import util.localization.WebLocalization;

@ManagedBean(name = "enumTime24H")
@RequestScoped
public class EnumTime24H {
    private WebLocalization localization;
    //  user preferred locale
    private String preferredLocale;
    //The list with the items
    public List<SelectItem> listItems = null;

    /** Creates a new instance of EnumTime24H */
    public EnumTime24H() {
        /* LOCALIZATION */
        localization = new WebLocalization();
        preferredLocale = localization.getPreferredLocaleFromSession();

        /* END LOCALIZATION */
        // load combobox
        loadCombo();
    }

    //Loading the items
    private void loadCombo() {
        listItems = new ArrayList<SelectItem>();
        //listItems.add(new SelectItem(null, LocalizedSelect.getLocalizedSelectAsString(preferredLocale)));

        for (Time24H t : Time24H.values()) {
            String localizedTime24H = LocalizedTime24H.getLocalizedTime24HAsString(t, preferredLocale);
            listItems.add(new SelectItem(t, localizedTime24H));

        }
    }

    public List<SelectItem> getListItems() {
        return listItems;
    }

    public void setListItems(List<SelectItem> listItems) {
        this.listItems = listItems;
    }
}
